package br.com.dev.tcc.view;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;

public class DefaultSupportActionBarActivity extends SherlockFragmentActivity {

	/**
	 * Ajusta os textos e icone, alem de habilitar tecla 'back' da actionbar
	 * 
	 * @param titleStringId
	 * @param subtitleStringId
	 * @param iconResId
	 */
	protected void setActionBar(int titleStringId, int subtitleStringId,
			int iconResId) {

		setActionBar(titleStringId, iconResId);
		getSupportActionBar().setSubtitle(subtitleStringId);
	}

	/**
	 * Ajusta o titulo e o icone, alem de habilitar tecla 'back' da actionbar
	 * 
	 * @param titleStringId
	 * @param iconResId
	 */
	protected void setActionBar(int titleStringId, int iconResId) {

		getSupportActionBar().setTitle(titleStringId);
		getSupportActionBar().setIcon(iconResId);
		getSupportActionBar().setHomeButtonEnabled(true);
		getSupportActionBar().setDisplayHomeAsUpEnabled(true);
		getSupportActionBar().setDisplayShowHomeEnabled(true);
	}

	/**
	 * Chamado automaticamente quando o botao 'voltar' for pressionado na
	 * actionbar -> finaliza a activity atual
	 */
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {

		finish();

		return true;
	}
}